/**
 * Copyright (c) 2002-2011 旭鸣信息
 * All rights reserved. 
 * File：FileUploadImgInfoSave.java
 * History:
 *       2012-2-12: Initially created, tangkf.
 */
package com.xteam.web.controller.upload;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;

import com.tangkf.utils.fileupload.FileUploadUtils;
import com.xteam.purview.entities.SysPictureInfo;
import com.xteam.purview.service.impl.SystemPictureFace;

/**
 * @author tangkf ---2012-2-12
 */
public class FileProcesser implements IUploadProcess {

	static SystemPictureFace	picFace	= SystemPictureFace.getInstance();

	/**
	 * 处理图片文件的类
	 * @see cn.mystic.web.former.fileupload.IUploadProcess#process(org.apache.commons.fileupload.FileItem, java.lang.String)
	 */
	public String process(HttpServletRequest request, HttpServletResponse response, FileUploadUtils fuu, FileItem fileItem, String... param) {
		System.err.println("图片信息保存到图片数据库 的实现");
		String path = "", appId = "";
		if (param != null && param.length > 0) path = param[0];
		appId	= request.getParameter("appId")+"";

		SysPictureInfo spi = new SysPictureInfo();
		spi.setPicDesc(fileItem.getName());
		spi.setPicName(fileItem.getName());
		spi.setPicPath(path);
		spi.setAppId(appId);
		picFace.save(spi);

		// 定义默认返回信息
		String rinfo = "{'imgPath':'" + path + "','imgName':'" + fileItem.getName() + "'}";
		return rinfo;
	}
}
